#!/bin/bash

VERSION=$(grep -e 'smap \(.*\)' debian/changelog | head -n1 |grep -Eoe '([0-9]+[\.\-])*[0-9]*')
echo building version $VERSION
rm -rf dist
rm -rf smap/schema
cp -rp ../schema smap
python setup.py sdist
cd dist
tar zxvf *.tar.gz
SOURCE=$(find . -maxdepth 1 -type d -name 'Smap*' -print )
echo source dir is  $SOURCE
cd $SOURCE
dpkg-buildpackage -rfakeroot -uc -us -S
cd ..
debsign -kCCA095BD smap_*.changes

echo "run 'dput smap-ppa smap_...changes' in dist/"
